<?

namespace api\system\controller;

use cmf\controller\RestBaseController;

class AuthController extends RestBaseController {
    //更新授权
    public function update() {
        $file = CMF_ROOT . 'public/key.txt';
        $re = file_get_contents('http://key.tuddd.com/api/key.php?key=' . urlencode(file_get_contents($file)));
        if ($re) {
            $re = json_decode($re);
            if ($re->status == 'success') {
                file_put_contents($file, $re->key);
                $this->error('更新成功');
            }
        }
        $this->error('连接授权服务器失败');

    }
}
